package com.mazewithtraps.app;

import android.app.Activity;
import android.graphics.Color;
import android.view.View;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.Window;
import android.view.WindowManager;
import vizualize.mazePainter;
import maze.engine;

/**
 * Created by Роман on 06.05.14.
 */
public class PlayActivity extends Activity
{
    engine mazeEngine;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

        setContentView(R.layout.activity_play);

        Display display = getWindowManager().getDefaultDisplay();
        DisplayMetrics metricsB = new DisplayMetrics();
        display.getMetrics(metricsB);
        int size = 0;
        size = getIntent().getExtras().getInt("size");
        mazePainter maze = (mazePainter)findViewById(R.id.maze_view);
        maze.setParams(metricsB.widthPixels, metricsB.heightPixels, size);
        mazeEngine = new engine(size, maze);
        maze.init();
        maze.drawHero(0, 0, Color.rgb(255, 0, 0));

    }
    public void bowButton_Clicked(View v)
    {
       mazeEngine.endOfGame();
    }

    public void leftButton_Clicked(View v)
    {
        mazeEngine.step(3);
    }

    public void rightButton_Clicked(View v)
    {
        mazeEngine.step(4);
    }

    public void upButton_Clicked(View v)
    {
        mazeEngine.step(1);
    }

    public void downButton_Clicked(View v)
    {
        mazeEngine.step(2);
    }

    public void dropButton_Clicked(View v)
    {
        mazeEngine.dropKey();
    }

    public void healButton_Clicked(View v)
    {
        mazeEngine.healing();
    }
}

